{% extends "../../layui/layouts/main.html" %}

{% block mainbody %}
<div id="menu-index">

    <script type="text/html" id="tool">
        {% verbatim %}
        {{# if(d.status === 1){ }}
            <a class="layui-btn layui-btn-warm layui-btn-xs" lay-event="wanjie" data-status="{{d.status}}">{{d.status_label}}</a>
        {{#  } }}
        {{# if(d.status === 2){ }}
            <a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="wanjie" data-status="{{d.status}}">{{d.status_label}}</a>
        {{#  } }}
            <a class="layui-btn layui-btn-danger layui-btn-xs" href="/discuss-detail?pid={{d.pid}}">反馈（{{d.count}}）</a>
        {% endverbatim %}
    </script>

    {% include "_search.tpl" %}

    <div class="layui-card">
        <div class="layui-card-header yak-card-header">
            {{Header}}
        </div>
        <div class="layui-card-body">
            <table id="drug-table" lay-filter="drug-table-filter"></table>
        </div>
    </div>

</div>
{% endblock %}

{% block script %}
<script>
    layui.use(['grid', 'layarea', 'laydate'], function () {
        var pager = layui.grid
            , layarea = layui.layarea
            , laydate = layui.laydate
            , tableId = "drug-table"
            , laytpl = layui.laytpl
            , tableFilter = "drug-table-filter"
            , searchFilter = "drug-search"
            , cols = [
                {width: 60, field: "_serial", title: "序号"},
                {field: "comment", title: "反馈内容"},
                {fixed: 'right', width: 300, align: 'center', toolbar: '#tool'}
            ]
            , table = {
                "id": tableId,
                "elem": "#" + tableId,
                "limit": 8,
                "limits": [10, 20, 50, 100],
                "cols": [cols],
                "method": "post",
                "request": {"pageName": "page", "limitName": "per-page"},
                "url": "/discuss-category",
                // "toolbar": "#toolBar",
                "page": {"hash": "fenye"},
                "autoSort": false,
                "defaultToolbar": []
            }
            , eventOptions = {
                "wanjie": {"url": "/discuss-category/wanjie"},
            }
            , events = {
                "wanjie": function (obj, config, that) {
                    layer.msg('是否设置反馈完结？', {
                        time: 20000,
                        btn: ['完结', '取消']
                        ,btn1: function(index, layero){
                            var $ax = layui.ax;
                            var ajax = new $ax(config.url, function (res) {
                                that.reloadTable(null, null, true);
                                layer.close(index)
                            });
                            ajax.setMethod('post');
                            ajax.setDataValue("pid", obj.data['pid']);
                            ajax.send();
                        }
                    });
                    return false
                }
            }

        layarea.render({
            elem: '#'+ searchFilter,
            change: function (res) {
                //选择结果
                console.log(res)
            }
        });

        laydate.render({
            elem: '#yak_dt_s'
        });

        laydate.render({
            elem: '#yak_dt_e'
        });

        pager.render({
            "searchFilter": searchFilter,
            "tableId": tableId,
            "tableFilter": tableFilter,
            "sort": "server",
            "countCache": true,
            "table": table,
            "editor": {},
            "eventOptions": eventOptions
        }, events)

    })
</script>
{% endblock %}